package com.atguigu.gulimall.order.controller;

import com.atguigu.gulimall.order.entity.OrderEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class SendMsg {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @GetMapping("send")
    public void sendTest() {
        //发送消息
        OrderEntity orderEntity = new OrderEntity();
        orderEntity.setNote("这是一首简单的小情歌");
        for (int i = 0; i < 3; i++) {
            rabbitTemplate.convertAndSend("hello-java-exchange","hello.java",orderEntity);
        }
        log.info("消息发送完成--",orderEntity);
    }
}
